﻿package Welsy4.Connect.business 
{
	
	import flash.net.URLVariables;
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.http.HTTPService;
	
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import Welsy4.Connect.vo.User;
	import Welsy4.Connect.model.ConnectModel;
	
	public class PrincipalListDelegate 
	{
		
		private var responder : IResponder;
        private var service : Object;
                
        public function PrincipalListDelegate( responder : IResponder ){
            this.service = ServiceLocator.getInstance().getHTTPService("FakeAPI" );
            this.responder = responder;
        }
		
		/*
		 *  @title Generica function setPermission gestisce tutte le richieste di permission. Manda l'URLVariables al servere delle richieste
		 *  @param permissionRequest:URLVariables see pag 53
		 *  @return void
		 * 
		 * */
		public function findUserByLogin(login:String):void {
		    
			var permissionRequest:URLVariables = new URLVariables("action=principal-list&filter-login="+login);
			// add custom nocache param
			permissionRequest.nocache = User.getLoginRequestlocaleTime();
			if(ConnectModel.getInstance().sessionCookie.length > 0){
				permissionRequest.session = ConnectModel.getInstance().sessionCookie;
			}
			
			var token : AsyncToken = HTTPService(service).send(permissionRequest);
			token.addResponder(responder);
		}
		
	
		
        
		
		
	}
	
}